#!/bin/sh

uci -q batch <<-EOF >/dev/null
	delete ucitrack.@frps[-1]
	add ucitrack frps
	set ucitrack.@frps[-1].init=frps
	commit ucitrack
EOF

frps=$(uci -q get frps.@frps[-1])

if [ -z "$frps" ]; then
	uci -q add frps frps
fi

if [ "x$frps" != "xmain" ]; then
	uci -q batch <<-EOF >/dev/null
		rename frps.@frps[-1]="main"
		set frps.main.enabled="0"
		commit frps
	EOF
fi

rm -rf /tmp/luci-indexcache /tmp/luci-modulecache
exit 0
